package org.osdtsystem.utils;

import java.util.LinkedHashMap;
import java.util.Map;

public class CacheMap<X, Y> extends LinkedHashMap<X, Y> {
    int cacheSize;

    public CacheMap(final int cacheSize) {
        super(cacheSize, 0.75F, true);
        this.cacheSize = cacheSize;
    }

    public void setCacheSize(final int cacheSize) {
        this.cacheSize = cacheSize;
    }

    @Override
    protected boolean removeEldestEntry(final Map.Entry<X, Y> eldest) {
        return size() > cacheSize;
    }
}
